package com.zhubayi.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 祝八一
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private AdminInterceptor adminInterceptor;
    @Autowired
    private UserInterceptor userInterceptor;


    /**
     * 注册自定义的拦截器，并且定义拦截规则
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptor).addPathPatterns("/admin/**","/category/**").excludePathPatterns("/admin/tologin","/admin/safecode","/admin/login");
        registry.addInterceptor(userInterceptor).addPathPatterns("/user/**").excludePathPatterns("/user/exist","/user/register","/user/toLogin","/user/login","/user/toReg","/toReg");

    }
}
